import "reflect-metadata";

const ParamsTypeMetaKey = Symbol("design:paramtypes");
const ReturnTypeMetaKey = Symbol("design:returntype");

function Type(type) {
  return Reflect.metadata("design:type", type);
}

function ParamTypes(...types) {
  return Reflect.metadata(ParamsTypeMetaKey, types);
}

function ReturnType(type) {
  return Reflect.metadata(ReturnTypeMetaKey, type);
}

function ParseMethod(type) {
  return Reflect.metadata("data:parse", type);
}

class P {}

export class Point {
  private x: number;
  private y: number;

  constructor(x, y) {
    this.x = x;
    this.y = y;
  }

  @ReturnType("[number, number]")
  getCoord() {
    return [this.x, this.y];
  }

  @ParamTypes(Number)
  @ReturnType(P)
  @ParseMethod("JSON")
  moveX(x: number) {
    this.x = x;
    return this;
  }
}

const p = new Point(3, 9);

const desc = Reflect.getMetadata(ReturnTypeMetaKey, p, "getCoord")
const moveXParamsType = Reflect.getMetadata(ParamsTypeMetaKey, p, "moveX");
console.log('moveXParamsType: ', moveXParamsType);
console.log('desc: ', desc);
